/*-
 * #%L
 * HAPI FHIR JPA Server
 * %%
 * Copyright (C) 2014 - 2025 Smile CDR, Inc.
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */
package ca.uhn.fhir.jpa.config;

import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.jpa.api.config.JpaStorageSettings;
import ca.uhn.fhir.jpa.api.dao.DaoRegistry;
import ca.uhn.fhir.jpa.api.svc.IIdHelperService;
import ca.uhn.fhir.jpa.bulk.export.api.IBulkExportProcessor;
import ca.uhn.fhir.jpa.bulk.export.svc.BulkExportHelperService;
import ca.uhn.fhir.jpa.bulk.export.svc.JpaBulkExportProcessor;
import ca.uhn.fhir.jpa.dao.SearchBuilderFactory;
import ca.uhn.fhir.jpa.dao.tx.IHapiTransactionService;
import ca.uhn.fhir.jpa.model.dao.JpaPid;
import ca.uhn.fhir.mdm.svc.MdmExpandersHolder;
import ca.uhn.fhir.rest.server.util.ISearchParamRegistry;
import jakarta.persistence.EntityManager;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class JpaBulkExportConfig {
	@Bean
	public IBulkExportProcessor<JpaPid> jpaBulkExportProcessor(
			FhirContext theFhirContext,
			BulkExportHelperService theBulkExportHelperService,
			JpaStorageSettings theJpaStorageSettings,
			DaoRegistry theDaoRegistry,
			SearchBuilderFactory<JpaPid> theSearchBuilderFactory,
			IIdHelperService<JpaPid> theIdHelperService,
			EntityManager theEntityManager,
			IHapiTransactionService theHapiTransactionService,
			ISearchParamRegistry theSearchParamRegistry,
			MdmExpandersHolder theMdmExpandersHolder) {
		return new JpaBulkExportProcessor(
				theFhirContext,
				theBulkExportHelperService,
				theJpaStorageSettings,
				theDaoRegistry,
				theSearchBuilderFactory,
				theIdHelperService,
				theEntityManager,
				theHapiTransactionService,
				theSearchParamRegistry,
				theMdmExpandersHolder);
	}

	@Bean
	public BulkExportHelperService bulkExportHelperService() {
		return new BulkExportHelperService();
	}
}
